package com.insuremonitor.system.service.impl;

import com.insuremonitor.common.core.domain.AjaxResult;
import com.insuremonitor.common.utils.DateUtils;
import com.insuremonitor.system.domain.FrontInsureRateGoods;
import com.insuremonitor.system.mapper.FrontInsureRateGoodsMapper;
import com.insuremonitor.system.service.IFrontInsureRateGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 货物类型与费率的关系Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-11-21
 */
@Service
public class FrontInsureRateGoodsServiceImpl implements IFrontInsureRateGoodsService 
{
    @Autowired
    private FrontInsureRateGoodsMapper frontInsureRateGoodsMapper;

    /**
     * 查询货物类型与费率的关系
     * 
     * @param insureGoodsId 货物类型与费率的关系主键
     * @return 货物类型与费率的关系
     */
    @Override
    public FrontInsureRateGoods selectFrontInsureRateGoodsByInsureGoodsId(Long insureGoodsId)
    {
        return frontInsureRateGoodsMapper.selectFrontInsureRateGoodsByInsureGoodsId(insureGoodsId);
    }

    /**
     * 查询货物类型与费率的关系列表
     * 
     * @param frontInsureRateGoods 货物类型与费率的关系
     * @return 货物类型与费率的关系
     */
    @Override
    public List<FrontInsureRateGoods> selectFrontInsureRateGoodsList(FrontInsureRateGoods frontInsureRateGoods)
    {
        frontInsureRateGoods.setStatus("1");
        return frontInsureRateGoodsMapper.selectFrontInsureRateGoodsList(frontInsureRateGoods);
    }

    /**
     * 新增货物类型与费率的关系
     * 
     * @param frontInsureRateGoods 货物类型与费率的关系
     * @return 结果
     */
    @Override
    public AjaxResult insertFrontInsureRateGoods(FrontInsureRateGoods frontInsureRateGoods)
    {
        frontInsureRateGoods.setCreateTime(DateUtils.getNowDate());
        int i =  frontInsureRateGoodsMapper.insertFrontInsureRateGoods(frontInsureRateGoods);
        if(i>0){
            return AjaxResult.success("操作成功",frontInsureRateGoods.getInsureGoodsId());
        }else {
            return AjaxResult.error("操作失败");
        }
    }

    /**
     * 修改货物类型与费率的关系
     * 
     * @param frontInsureRateGoods 货物类型与费率的关系
     * @return 结果
     */
    @Override
    public int updateFrontInsureRateGoods(FrontInsureRateGoods frontInsureRateGoods)
    {
        frontInsureRateGoods.setUpdateTime(DateUtils.getNowDate());
        return frontInsureRateGoodsMapper.updateFrontInsureRateGoods(frontInsureRateGoods);
    }

    /**
     * 批量删除货物类型与费率的关系
     * 
     * @param insureGoodsIds 需要删除的货物类型与费率的关系主键
     * @return 结果
     */
    @Override
    public int deleteFrontInsureRateGoodsByInsureGoodsIds(Long[] insureGoodsIds)
    {
        return frontInsureRateGoodsMapper.deleteFrontInsureRateGoodsByInsureGoodsIds(insureGoodsIds);
    }

    /**
     * 删除货物类型与费率的关系信息
     * 
     * @param insureGoodsId 货物类型与费率的关系主键
     * @return 结果
     */
    @Override
    public int deleteFrontInsureRateGoodsByInsureGoodsId(Long insureGoodsId)
    {
        return frontInsureRateGoodsMapper.deleteFrontInsureRateGoodsByInsureGoodsId(insureGoodsId);
    }
}
